/**
 * Object.freeze(obj)
 * 不可添加新属性
 * 默认把configurable设置为false，writable设置为false，不可修改属性描述符号
 * 不可删除属性
 * 不可修改属性的值
 */

const obj = { name: 'jeff' };
console.log('before freeze: ', Object.getOwnPropertyDescriptors(obj));

Object.freeze(obj);

obj.age = 23;

console.log('obj is frozen: ', Object.isFrozen(obj));
console.log('after add new property obj: ', obj);
console.log('after freeze: ', Object.getOwnPropertyDescriptors(obj));

obj.name = 'feng';

console.log('after change value obj: ', obj);

// Object.defineProperty(obj, 'name', { enumerable: false }); // 不可defined
// Object.defineProperty(obj, 'name', { writable: true }); // writable  不可由false改为true
console.log(
  'after change writable to true: ',
  Object.getOwnPropertyDescriptors(obj)
);

delete obj.name;

console.log('after delete name obj: ', obj);
